<?php
    
    function row_num($res) {
        $nrows = 0;
        $res->reset();
        while ($res->fetchArray()) {
            $nrows = $nrows + 1;
        }
        $res->reset();
        return $nrows;
    }